import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sainbainu/common/values/colors.dart';
import 'package:sainbainu/common/widgets/widget.dart';

import '../index.dart';

class BottomActionBar extends GetView<ContentDetailController> {
  final CommentTap? onCommentTap;
  final LikeTap? onLikeTap;
  final LikeTap? onCollectionTap;
  final ShareTap? onShareTap;

  const BottomActionBar({
    super.key,
    this.onCommentTap,
    this.onLikeTap,
    this.onCollectionTap,
    this.onShareTap,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: SafeArea(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              height: 0.5,
              color: AppColors.border,
            ),
            Obx(
              () => AnimatedContainer(
                duration: const Duration(milliseconds: 300),
                height: controller.state.showCommentInput.value ? 40 : 0,
                child: Padding(
                  padding: const EdgeInsets.fromLTRB(15, 6, 15, 0),
                  child: CommentInput(onTap: onCommentTap),
                ),
              ),
            ),
            SizedBox(
              height: 44,
              child: GetBuilder<ContentDetailController>(
                id: 'contentInfo',
                builder: (_) => IconNumRow(
                  mainAxisAlignment: MainAxisAlignment.center,
                  giveFlag: _.state.contentInfo.giveFlag ?? 0,
                  giveNum: _.state.contentInfo.giveNum ?? 0,
                  collectionFlag: _.state.contentInfo.collectionFlag ?? 0,
                  collectionNum: _.state.contentInfo.collectionNum ?? 0,
                  visitNum: _.state.contentInfo.visitNum ?? 0,
                  commentNum: _.state.contentInfo.commentNum ?? 0,
                  shareNum: _.state.contentInfo.shareNum ?? 0,
                  onCommentTap: onCommentTap,
                  onLikeTap: onLikeTap,
                  onCollectionTap: onCollectionTap,
                  onShareTap: onShareTap,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
